package com.hehao.java_basic.proxy.cglib.dynamic;

import org.junit.Test;
import org.springframework.cglib.core.DebuggingClassWriter;

/**
 * @author Damon
 * @date 2022/10/26
 */
public class CglibDynamicProxyTest {
    @Test
    public void usbSell() {
        CglibKingstonFactory kingstonProxy = (CglibKingstonFactory) CglibProxyFactory.getProxy(CglibKingstonFactory.class,new UsbSellInterceptor());
        System.out.println(kingstonProxy.usbSell(1));
    }

    @Test
    public void sendMessage() {
        //cglib动态代理设置动态代理产生的类地址
        System.setProperty(DebuggingClassWriter.DEBUG_LOCATION_PROPERTY, "D:\\develop\\workspace\\Damon_Study\\Common\\target\\classes");
        AliSmsService aliSmsService = (AliSmsService) CglibProxyFactory.getProxy(AliSmsService.class,new DebugMethodInterceptor());
        aliSmsService.send("java");
    }

}
